package com.metaera.app.ui.activities;

import android.graphics.drawable.Drawable;
import android.os.Bundle;

import com.metaera.app.R;
import com.metaera.app.controller.presenter.FeedbackHistoryPresenter;
import com.metaera.app.ui.adapters.FeedbackHistoryAdapter;
import com.metaera.app.ui.core.BaseRequestActivity;
import com.metaera.app.utils.ActivityTitleHelper;
import com.metaera.app.utils.ViewUtils;
import com.scwang.smart.refresh.layout.SmartRefreshLayout;

import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.RecyclerView;

public class FeedbackHistoryActivity extends BaseRequestActivity {

    @Override
    protected int getTitleLayoutRes() {
        return R.layout.include_activity_title;
    }

    @Override
    protected int getContentLayoutId() {
        return R.layout.include_smart_refresh_recycler_view;
    }

    @Override
    protected void initialize(Bundle savedInstanceState) {
        ViewUtils.addStatusBarHeightPadding(findViewById(R.id.layout_title_container));

        // find view
        RecyclerView recyclerView = findViewById(R.id.recycler_view);
        SmartRefreshLayout refreshLayout = findViewById(R.id.smart_refresh_layout);

        // init view
        ActivityTitleHelper.setTitle(this, R.string.feedback_history_text);
        refreshLayout.setEnableRefresh(false);
        refreshLayout.setEnableLoadMore(false);

        FeedbackHistoryAdapter adapter = new FeedbackHistoryAdapter();
        recyclerView.setAdapter(adapter);
        DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(recyclerView.getContext(), DividerItemDecoration.VERTICAL);
        Drawable drawable = ContextCompat.getDrawable(recyclerView.getContext(), R.drawable.shape_item_divider);
        dividerItemDecoration.setDrawable(drawable);
        recyclerView.addItemDecoration(dividerItemDecoration);

        // network
        FeedbackHistoryPresenter presenter = new FeedbackHistoryPresenter();
        presenter.setModelAndView(adapter::setList);
        presenter.execute();
    }

}
